package com.ruoyi.project.NH.base_family_info.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.NH.base_family_info.domain.BaseFamilyInfo;
import com.ruoyi.project.NH.base_family_info.service.IBaseFamilyInfoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 农户收入信息管理Controller
 *
 * @author 狗熊岭
 * @date 2023-07-23
 */
@RestController
@RequestMapping("/NH/base_family_info")
public class BaseFamilyInfoController extends BaseController
{
    @Autowired
    private IBaseFamilyInfoService baseFamilyInfoService;

    /**
     * 查询农户收入信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('NH:base_family_info:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseFamilyInfo baseFamilyInfo)
    {
        startPage();
        List<BaseFamilyInfo> list = baseFamilyInfoService.selectBaseFamilyInfoList(baseFamilyInfo);
        return getDataTable(list);
    }

    /**
     * 导出农户收入信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('NH:base_family_info:export')")
    @Log(title = "农户收入信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseFamilyInfo baseFamilyInfo)
    {
        List<BaseFamilyInfo> list = baseFamilyInfoService.selectBaseFamilyInfoList(baseFamilyInfo);
        ExcelUtil<BaseFamilyInfo> util = new ExcelUtil<BaseFamilyInfo>(BaseFamilyInfo.class);
        util.exportExcel(response, list, "农户收入信息管理数据");
    }

    /**
     * 获取农户收入信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('NH:base_family_info:query')")
    @GetMapping(value = "/{fid}")
    public AjaxResult getInfo(@PathVariable("fid") String fid)
    {
        return success(baseFamilyInfoService.selectBaseFamilyInfoByFid(fid));
    }

    /**
     * 新增农户收入信息管理
     */
    @PreAuthorize("@ss.hasPermi('NH:base_family_info:add')")
    @Log(title = "农户收入信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseFamilyInfo baseFamilyInfo)
    {
        return toAjax(baseFamilyInfoService.insertBaseFamilyInfo(baseFamilyInfo));
    }

    /**
     * 修改农户收入信息管理
     */
    @PreAuthorize("@ss.hasPermi('NH:base_family_info:edit')")
    @Log(title = "农户收入信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseFamilyInfo baseFamilyInfo)
    {
        return toAjax(baseFamilyInfoService.updateBaseFamilyInfo(baseFamilyInfo));
    }

    /**
     * 删除农户收入信息管理
     */
    @PreAuthorize("@ss.hasPermi('NH:base_family_info:remove')")
    @Log(title = "农户收入信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fids}")
    public AjaxResult remove(@PathVariable String[] fids)
    {
        return toAjax(baseFamilyInfoService.deleteBaseFamilyInfoByFids(fids));
    }
}
